const{Sequelize,Model,DataTypes}=require('sequelize');
let database ={
    host:"localhost",
    user:"root",
    password:"root",
    database:"mydb"
};
const sequelize=new Sequelize(database.database,database.user,database.password,{
    dialect:'mysql',
    host:database.host,
    port:database.port,
    logging:false,
    timezone: '+08:00',
    define: {
        timestamps: false,
    }
});
sequelize.sync({ force: false });
class Student extends Model { };
Student.init({
    s_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement:true
    },
    s_name: {
        type: DataTypes.STRING
       
    },
    score:{
        type: DataTypes.INTEGER
    }

    },{
        sequelize,
        modelName: 'student',
        
        tableName: 'student',
    }
);
let newS=new Student({s_name:'邓富裕',score:creatScore()})
newS.save();
function creatScore(){
    let num=Math.floor(Math.random()*101);
    return num;
}
